package com.zhang.spring.Test;


import javax.annotation.Resource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.zhang.spring.pojo.User;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class DemoTest {

	@Test
	public void testname() {
	ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
	User bean = ac.getBean(User.class);
//	User bean = (User)ac.getBean("User");
//	System.out.println(bean==bean2);//@Scope(scopeName="singleton")true---------@Scope(scopeName="prototype")false
	System.out.println(bean);
	ac.close();
	}
//	spring的junit测试
	@Resource(name="user")
	private User u;
	
	@Test
	public void testname02() {
		System.out.println(u);
	
	}
}
